/* Copyright (C) YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function($){

	$(document).ready(function() {

		var config = $('body').data('config') || {};

		// Accordion menu
		$('.menu-sidebar').accordionMenu({ mode:'slide' });

		// Dropdown menu
		$('#menu').dropdownMenu({ mode: ($.support.opacity ? 'showhide' : 'slide'), dropdownSelector: 'div.dropdown'});

		// Smoothscroller
		$('a[href="#page"]').smoothScroller({ duration: 500 });

		// Fix Browser Rounding
		$('.grid-block').matchWidth('.grid-h');

		// Social buttons
		$('article[data-permalink]').socialButtons(config);

		// Match height of div tags
		var matchHeight = function(){
			$('#top-a .grid-h').matchHeight('.deepest');
			$('#top-b .grid-h').matchHeight('.deepest');
			$('#bottom-a .grid-h').matchHeight('.deepest');
			$('#bottom-b .grid-h').matchHeight('.deepest');
			$('#innertop .grid-h').matchHeight('.deepest');
			$('#innerbottom .grid-h').matchHeight('.deepest');
		//	$('#maininner, #sidebar-a, #sidebar-b').matchHeight();
		};
		
		matchHeight();
		
		var heightgreeting = jQuery('div.greeting').height();
		var heightcontent = jQuery('div#maininner').height();
	//	var totalheight = 0;
		//if(heightmenu<0)
	//		totalheight  = heightgreeting;
	//	else
	//	var	totalheight = heightmenu + heightgreeting;
		
		var totalheight = jQuery("#sidebar-a").height();
	//	alert (totalheight)
	//	alert(heightcontent+'-'+totalheight);
		if(totalheight > heightcontent){
			jQuery('#content').css('min-height',totalheight-41+'px');
		//	var totalh = heightgreeting+(totalheight-heightcontent);
		
		//	jQuery('div.greeting .slides').css('min-height',totah-3+'px');
		}else{
			
			var totalh = heightgreeting+(heightcontent-totalheight);
		//	jQuery('#content').css('min-height',totalh+'px');
		//	alert(heightmenu);
		//	if(heightmenu==0)
				jQuery('div.greeting .slides').css('min-height',totalh-32+'px');
		}
			
		
		$(window).bind("load", matchHeight);
		
	});
	
})(jQuery);



